Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
Using Dynamic Queries and Buffers
In the previous chapter you learned how to create dynamic versions of visual objects to increase the flexibility of your application’s user interface. You also learned how to use handles to access the attributes and methods of those objects as well as their static counterparts. In this chapter you’ll learn how to do the same with data management objects such as queries and buffers. The next chapters continue with a discussion of temp-tables and the browse. The same principles apply to visual objects, so the concepts should already be familiar to you.
Using a dynamic query, you can postpone until run time the tasks of defining what table or tables a query should use, and what the selection criteria should be for the result set the query manages. Using a dynamic buffer, you can likewise allow the application to identify at run time what table a buffer should store data for.
Putting these dynamic objects together with dynamic temp-tables and browses gives you the ability to define almost any aspect of your application at run time, when this is necessary. Although you shouldn’t make all your queries and buffers dynamic any more than you should make all your user interface objects dynamic, having the ability to do so allows you to build general purpose tools for certain parts of your application that might need to deal with a wide variety of user requirements in a consistent way. Being able to do this from a single procedure with dynamic objects is greatly preferable to writing and compiling many different procedures that do essentially the same job for different tables or fields.
It’s important to note that these dynamic features are not meant to replace all the static statements in earlier versions of the Progress 4GL, or to be the standard way to write code for all new applications. There is a significant performance cost to using dynamic data management statements, which can be well worth the cost when the flexibility is needed but an unnecessary expense and complication, otherwise. If your tables, fields, and queries are known and fixed when you write the procedure, then there is no need to use dynamic statements to manage them. Likewise, if you have a static object, such as a query, on a specific table or tables but need to modify just the
WHEREclause at run time or access some of its attributes and methods, you can easily do this through a handle attached to the static object. This keeps your code simpler and more efficient.This chapter and the one that follows include straightforward but fairly comprehensive examples that show the power of dynamic data management objects, allowing you to browse data from any database table or temp-table you care to define. By the end of these two chapters, you’ll have a solid understanding of some of the most powerful features in the Progress 4GL and how best to use them in your applications.
This chapter includes the following sections:
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |